package com.hjqjl.whdemo.utils;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;

/**
 * 获取Throwable里头的错误信息
 */
public class ThrowableMessageUtil {
    public static String getMessage(Throwable e) {
        try {
            Writer result = new StringWriter();
            PrintWriter printWriter = new PrintWriter(result);
            e.printStackTrace(printWriter);
            return result.toString();
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        return "";
    }
}